import store from '@/store'

export default {
  install(Vue) {
    Vue.prototype.ishas = (value, modelId) => {

      const permissionList = store.getters && store.getters.permissionList
      if (!value) return false
      // const modelId = vnode.context._routerRoot._route.meta.modelId || ''

      if (!modelId) return false
      const list = permissionList.filter(o => o.modelId === modelId)

      if (!list.length) return false
      const btnList = list[0] && list[0].button ? list[0].button : []

      // console.log('btnList+++btnList', btnList)
      if (!btnList.length) {
        el.parentNode && el.parentNode.removeChild(el)
      } else {
        const hasPermission = btnList.some(btn => btn.enCode === value)


        if (!hasPermission) {
          return false
        }
      }
    }

  }
}